package com.gee.spring.boot.oauth2.auth.config.web;

import com.gee.spring.boot.oauth2.common.util.http.ResponseUtil;
import com.gee.spring.boot.oauth2.common.util.result.ResultCode;
import com.gee.spring.boot.oauth2.common.util.result.ResultUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * desc:
 *
 * @author gee
 * @date 2020/04/01 22:47
 */
@Component(value = "authenticationSuccessHandler")
public class GeeAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        ResponseUtil.writeJson(response, ResultUtil.success(ResultCode.LOGIN_SUCCESS));
    }
}
